package cn.liyunqi.ttv.web.common;


import cn.liyunqi.core.common.Constants;
import cn.liyunqi.core.exception.BizException;
import cn.liyunqi.core.util.PageHelper;

import java.util.HashMap;

@SuppressWarnings("hiding")
public class ResponseMap<String, Object> extends HashMap<String, Object> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	
	@SuppressWarnings("unchecked")
	public ResponseMap(){
		super();
		this.put((String) Message.STATUS, (Object)Message.STATUS_NORMAL);
		this.put((String) Message.MESSAGE, (Object)Constants.EMPTY);
	}
	
	@SuppressWarnings("unchecked")
	public ResponseMap<String, Object> returnError(BizException biz){
		this.put((String)Message.STATUS, (Object)biz.getStatus());
		this.put((String)Message.MESSAGE, (Object)biz.getMessage());
		return this;
	}
	@SuppressWarnings("unchecked")
	public ResponseMap<String, Object> returnError(String msg){
		this.put((String)Message.STATUS, (Object)Message.STATUS_ERROR);
		this.put((String)Message.MESSAGE, (Object)msg);
		return this;
	}
	@SuppressWarnings("unchecked")
	public ResponseMap<String, Object> returnError(){
		this.put((String)Message.STATUS, (Object)Message.STATUS_ERROR);
		this.put((String)Message.MESSAGE, (Object)Message.ERROR_001);
		return this;
	}
	@SuppressWarnings("unchecked")
	public ResponseMap<String, Object> returnSuccess(){
		this.put((String) Message.STATUS, (Object)Message.STATUS_NORMAL);
		this.put((String) Message.MESSAGE, (Object)Constants.EMPTY);
		return this;
	}
	
	@SuppressWarnings("unchecked")
	public ResponseMap<String, Object> putPage(PageHelper pageHelper){
		this.put((String)PageHelper.PAGE, (Object)pageHelper.getPage());
		this.put((String)PageHelper.PAGESIZE, (Object)pageHelper.getPageSize());
		this.put((String)PageHelper.COUNT, (Object)pageHelper.getCount());
		//this.put((String)"pageCount", (Object)pageHelper.getPageCount());
		return this;
	}
}
